package utils

import "reflect"

func CopyStruct(src, dest interface{}) error {
	srcVal := reflect.ValueOf(src).Elem()
	destVal := reflect.ValueOf(dest).Elem()

	for i := 0; i < srcVal.NumField(); i++ {
		srcField := srcVal.Field(i)
		srcFieldName := srcVal.Type().Field(i).Name

		destField := destVal.FieldByName(srcFieldName)
		if !destField.IsValid() || !destField.CanSet() {
			continue
		}

		destField.Set(srcField)
	}

	return nil
}

type PageResult struct {
	List interface{} `json:"list"`
	Page int `json:"page"`
	PageSize int `json:"pageSize"`
	Total int64 `json:"total"`
}